import csv

taxis = {}
for i in range(400):
    taxis[i] = []

with open('taxi_february.txt', 'rb') as filein:
    for line in filein:
        line_list = line.decode().strip('\n').split(';')
        line_list[2] = line_list[2].strip('POINT(').strip(')').split(' ')
        taxis[int(line_list[0])].append([line_list[1], float(line_list[2][0]), float(line_list[2][1])])


# taxis_map = folium.Map(location=[41.8836718276551, 12.4877775603346], zoom_start=12)

for i in range(400):
    if not taxis[i]:
        pass
    else:
        filename = './trajectory/' + str(i) + '.csv'
        with open(filename, 'w', newline='') as csvfile:
            spamwriter = csv.writer(csvfile)
            spamwriter.writerows(taxis[i])


# taxis_map.save("taxis_map2.html")
# webbrowser.open("taxis_map2.html")
